using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpgradeEye:Upgrade {

	float timeSinceShooting;
	bool fired;
	const float cooldown = 5;

	protected override void BurstDecidingEventHandler(object _sender,BurstDecidingEventArgs e) {
		base.BurstDecidingEventHandler(_sender,e);
		if(timeSinceShooting<cooldown)
			return;
		timeSinceShooting=0;
		e.stat.shots.Clear();
		e.stat.shots.AddLast("eye");
		e.stat.cooldownTime.AddMultiply(0,100000);
		e.stat.cooldownTime.AddAdd(0.5f,100001);
	}
	protected override void ShootingEventHandler(object _sender,ShootEventArgs e) {
		base.ShootingEventHandler(_sender,e);
		if(e.stat.shotTag!="eye") return;
		e.stat.ammoConsumption=0;
		e.stat.projectileCount.AddMultiply(0,10000);
		e.stat.projectileCount.AddAdd(1,10001);
		e.stat.ammoConsumption.AddMultiply(0,float.MaxValue);
		e.stat.projectile=ProjectileData.nameToData["CameraShot"];
		fired=true;

	}

	protected override void ProjectileFiringEventHandler(object _sender,ProjectileEventArgs e) {
		if(!fired) return;
		Projectile sender = _sender as Projectile;
		if(sender.data.name!="CameraShot") return;
		base.ProjectileFiringEventHandler(_sender,e);
	}

	public override void Update(object sender,WeaponEventArgs e) {
		base.Update(sender,e);
		timeSinceShooting+=deltaTime;
		if(timeSinceShooting<cooldown) AddProgression(timeSinceShooting/cooldown);
	}


}
